package com.suneee.quartz.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.suneee.quartz.QuartzManager;

public class QuartzJobCommonUtil {
	
	private static final Logger logger = LoggerFactory.getLogger(QuartzJobCommonUtil.class);  

	/**
	 * 建立定时任务
	 * @param scheduleConfigDao 
	 * @param shopDao
	 * @param businessGroup
	 * @param jobClass
	 */
	public static void build(String jobName,String businessGroup,Integer interval,Class<?> jobClass){
		logger.info("-----------jobName:" + jobName + ",businessGroup:" + businessGroup + ",building !-----------");
		String triggerName  = jobName+"trigger" ;//触发器名
		String triggerGroupName = businessGroup+"triggerGroup";//触发器组名
		QuartzManager.addJob(jobName, 
				businessGroup, 
				triggerName, 
				triggerGroupName, 
				jobClass,
				"0 */"+interval+" * * * ?",
				null);
		//"0/" + interval + " * * * * ?",
	}
	
	/**
	 * 启动任务
	 */
	public static void start(){
		logger.info("-----------All jobs start !-----------");
		QuartzManager.startJobs();
	}
}
